//void, Obj this, Settlement sett
int money;
int gold;
int i;
Item item;

if (!.AsUnit.IsValid) 
	return; 
 
if (!sett.IsValid)
	return;

if (sett.GetCentralBuilding.AsCatapult)
	return;

if( sett.GetCentralBuilding.IsHeirOf("BaseRuins") )
	return;        

// spoils of war

gold = GetConst("SpoilsOfWarGold");
money = .AsUnit.RemoveItemsOfType("Spoils of War");
if (money) {
	if(gold > 0){
		sett.SetGold(sett.gold + money * gold);
		sett.GoldConverted(money * gold);
	}
}

if(.AsUnit.IsValid){
	if(.AsUnit.IsHeirOf("Military")
	&& .AsUnit.player != 15){
		if(.HasItem("Pouch Gold")){
			for (i=1; i<=.item_count; i+=1){
			
				item = .GetItem(i);
				if (!item.IsValid) 
					continue;       
				if (item.name == "Pouch Gold"){
					if(item.use_count > 0){
						sett.SetGold(sett.gold + item.use_count);
						sett.GoldConverted(item.use_count);
						item.SetUseCount(0);
					}
				}       
			}
			.AsUnit.RemoveItemsOfType("Pouch Gold");
	    }
	                  
		if (.HasItem("Meat 1") || 
			.HasItem("Meat 2") || 
			.HasItem("Meat 3") || 
			.HasItem("Meat 4")){
			for (i=1; i<=.item_count; i+=1){
				item = .GetItem(i);
				if (!item.IsValid) 
					continue;       
				if (item.name == "Meat 1" ||
					item.name == "Meat 2" ||
					item.name == "Meat 3" ||
					item.name == "Meat 4"){
					if(item.use_count > 0){
						sett.SetFood(sett.food + item.use_count);
						item.SetUseCount(0);
					}
				}
			}
			.AsUnit.RemoveItemsOfType("Meat 1");
			.AsUnit.RemoveItemsOfType("Meat 2");
			.AsUnit.RemoveItemsOfType("Meat 3");
			.AsUnit.RemoveItemsOfType("Meat 4");
		}
		
		// mercenary pact
		if (EnvReadString(.player, "Mercenary pact")=="researched")
		{
			for (i=1; i<=.item_count; i+=1)
			{
				item = .GetItem(i);
				if (!item.IsValid) 
					continue;     
				if (item.name == "Gold")
				{
					if(item.use_count > 0){
						sett.SetGold(sett.gold + item.use_count);
						sett.GoldConverted(item.use_count);
						item.SetUseCount(0);
					}
				}       
			}
		}
    } else if(.AsUnit.IsHeirOf("BaseAnimal")){
		.Damage(100000);
	}
}
